package com.ruoyi.park.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.park.domain.ParkRecruitment;
import com.ruoyi.park.service.IParkRecruitmentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 园区企业招聘Controller
 *
 * @author yangyu
 * @date 2022-07-05
 */
@Api(tags = " 园区企业招聘")
@RestController
@RequestMapping("/parkRecruitment")
public class ParkRecruitmentController extends BaseController {
    @Autowired
    private IParkRecruitmentService parkRecruitmentService;

    /**
     * 查询园区企业招聘列表
     */
    @ApiOperation(value="查询园区企业招聘列表", notes="查询园区企业招聘列表")
    @PreAuthorize(hasPermi = "park:parkRecruitment:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkRecruitment parkRecruitment) {
        startPage();
        List<ParkRecruitment> list = parkRecruitmentService.selectParkRecruitmentList(parkRecruitment);
        return getDataTable(list);
    }

    /**
     * 导出园区企业招聘列表
     */
    @ApiOperation(value="导出园区企业招聘列表", notes="导出园区企业招聘列表")
    @PreAuthorize(hasPermi = "park:parkRecruitment:export")
    @Log(title = "园区企业招聘", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkRecruitment parkRecruitment) throws IOException {
        List<ParkRecruitment> list = parkRecruitmentService.selectParkRecruitmentList(parkRecruitment);
        ExcelUtil<ParkRecruitment> util = new ExcelUtil<ParkRecruitment>(ParkRecruitment.class);
        util.exportExcel(response, list, "园区企业招聘数据");
    }
    /**
     * 获取园区企业招聘详细信息
     */
    @ApiOperation(value="获取园区企业招聘详细信息", notes="获取园区企业招聘详细信息")
    @PreAuthorize(hasPermi = "park:parkRecruitment:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(parkRecruitmentService.selectParkRecruitmentById(id));
    }

    /**
     * 新增园区企业招聘
     */
    @ApiOperation(value="新增园区企业招聘", notes="新增园区企业招聘")
    @PreAuthorize(hasPermi = "park:parkRecruitment:add")
    @Log(title = "园区企业招聘", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkRecruitment parkRecruitment) {
        return toAjax(parkRecruitmentService.insertParkRecruitment(parkRecruitment));
    }

    /**
     * 修改园区企业招聘
     */
    @ApiOperation(value="修改园区企业招聘", notes="修改园区企业招聘")
    @PreAuthorize(hasPermi = "park:parkRecruitment:edit")
    @Log(title = "园区企业招聘", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkRecruitment parkRecruitment) {
        return toAjax(parkRecruitmentService.updateParkRecruitment(parkRecruitment));
    }

    /**
     * 删除园区企业招聘
     */
    @ApiOperation(value="删除园区企业招聘", notes="删除园区企业招聘")
    @ApiImplicitParam(name = "ids", value = "园区企业招聘ID数组", required = true,paramType = "path", allowMultiple=true, dataType = "String")
    @PreAuthorize(hasPermi = "park:parkRecruitment:remove")
    @Log(title = "园区企业招聘", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(parkRecruitmentService.deleteParkRecruitmentByIds(ids));
    }
}
